﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Tom.Algorithm;

namespace Tom.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            // Init. the GA engine
            GeneticEngine<GeneticChromReal> GA = new GeneticEngine<GeneticChromReal>(100);

            // Add stoping conditions
            GA.StopConditions.Add(new MaxIterGeneticStop(100));

            // Perform optimization
            GeneticIndividual<GeneticChromReal> opt = GA.Minimize(new GeneticOpReal(10), MyGAFunc);

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }

        public static double MyGAFunc(GeneticChromReal chromosome) {
            
            double sum = 0;
            for (int i=0; i < chromosome.Gene.Count; i++) 
                sum += Math.Pow(chromosome.Gene[i] - i, 2);

            return sum;
        }
    }
}
